from typing import Any
from config import sleep, driver, Keys
from my_config import STEPS, k

@STEPS.step('input')
def input(driver:driver, step:dict) -> None:
    """
    写入值到普通输入框
    """
    e = driver.find_element(step['location']['type'], step['location']['val'])
    
    e.send_keys(step['val'])

@STEPS.step('fuzzy_input')
def fuzzy_query(driver:driver, step:dict) -> None:
    """
    写入值到指定的模糊查询输入框
    """
    
    e = driver.find_element(step['location']['type'], step['location']['val'])
    e.send_keys(step['val'])
    e.click()

    sleep(0.8)
        
    e.send_keys(Keys.DOWN)
    e.send_keys(Keys.ENTER)

@STEPS.step('choice')
def choice(driver:driver, step:dict) -> None:
    """
    写入值到选择输入框
    """

    c = driver.find_element(step['location']['type'], step['location']['val'])
    c.click()

    sleep(0.8)
    for i in range(step['val']):
        k.tap_key(k.down_key)
            
    k.tap_key(k.enter_key)
        